#include "MColor.h"

CMColor CMColor::BLACK = CMColor( 0.0f , 0.0f , 0.0f );
CMColor CMColor::WHITE = CMColor( 1.0f , 1.0f , 1.0f );
CMColor CMColor::RED   = CMColor( 1.0f , 0.0f , 0.0f );
CMColor CMColor::GREEN = CMColor( 0.0f , 1.0f , 0.0f );
CMColor CMColor::BLUE  = CMColor( 0.0f , 0.0f , 1.0f );

RGBA CMColor::GetAsRGBA( void ) const
{
	unsigned char uiVal8;
	unsigned int  uiVal32 = 0;

	// Convert to 32bit pattern
	// (RGBA = 8888)

	// Red
	uiVal8 = static_cast<unsigned char>( r * 255 );
	uiVal32 = uiVal8 << 24;

	// Green
	uiVal8 = static_cast<unsigned char>( g * 255 );
	uiVal32 += uiVal8 << 16;

	// Blue
	uiVal8 = static_cast<unsigned char>( b * 255 );
	uiVal32 += uiVal8 << 8;

	// Alpha
	uiVal8 = static_cast<unsigned char>( a * 255 );
	uiVal32 += uiVal8;

	return uiVal32;
}

ARGB CMColor::GetAsARGB(void) const
{
	unsigned char uiVal8;
	unsigned int  uiVal32 = 0;

	// Convert to 32bit pattern
	// (ARGB = 8888)

	// Alpha
	uiVal8 = static_cast<unsigned char>( a * 255 );
	uiVal32 = uiVal8 << 24;

	// Red
	uiVal8 = static_cast<unsigned char>( r * 255 );
	uiVal32 += uiVal8 << 16;

	// Green
	uiVal8 = static_cast<unsigned char>( g * 255 );
	uiVal32 += uiVal8 << 8;

	// Blue
	uiVal8 = static_cast<unsigned char>( b * 255 );
	uiVal32 += uiVal8;

	return uiVal32;
}